﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:pg="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.VMXExtensions.Html.View"
                    xmlns:pgV="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.VMXExtensions.Html.ViewModel"
                    xmlns:converters="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Converters;assembly=Tum.PDE.ToolFramework.Modeling.Visualization">
                    
    <converters:BoolToUnderlineConverter x:Key="BoolToUnderlineConverter"/>
    <converters:BoolToOppositeConverter x:Key="BoolToOppositeConverter"/>
    <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
    
    <!-- Html editor template -->
    <DataTemplate DataType="{x:Type pgV:HtmlEditorViewModel}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border  Margin="0,2,0,2" x:Name="HeaderBorder" BorderBrush="Transparent" BorderThickness="2.0" Grid.Row="0">
                <TextBlock x:Name="HeaderTxtBlock" Margin="3,0,0,0" MinWidth="50" VerticalAlignment="Center"
                           Text="{Binding Path=PropertyDisplayName, Mode=OneTime}" TextTrimming="WordEllipsis" 
                           ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                           TextDecorations="{Binding Path=IsPropertyRequired, Converter={StaticResource BoolToUnderlineConverter}, Mode=OneWay}"/>
            </Border>
            <TabControl Grid.Row="1" Margin="0,2,0,2" TabStripPlacement="Bottom">
                <TabItem Header="Design">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="22"/>
                        </Grid.RowDefinitions>
                        <pg:HtmlRichTextEditor x:Name="htmlRichTextEditor" Grid.Row="0" Html="{Binding Path=PropertyValue, Mode=TwoWay}"/>
                        <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
                            <Button Margin="2,0,2,0" HorizontalAlignment="Right" VerticalAlignment="Center" Width="70"
                                    Command="{Binding Path=UpdateCommand, ElementName=htmlRichTextEditor}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Margin="0, 0, 2,0" Source="pack://application:,,,/Tum.PDE.ToolFramework.Images;component/Ribbon/Check-16.png" Width="16" Height="16"/>
                                    <TextBlock Text="OK"/>
                                </StackPanel>
                            </Button>
                            <Button Margin="2,0,2,0" HorizontalAlignment="Right" VerticalAlignment="Center" Width="70"
                                    Command="{Binding Path=CancelCommand, ElementName=htmlRichTextEditor}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Margin="0, 0, 2,0" Source="pack://application:,,,/Tum.PDE.ToolFramework.Images;component/Ribbon/Cancel-16.png" Width="16" Height="16"/>
                                    <TextBlock Text="Cancel"/>
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </Grid>                    
                </TabItem>
                <TabItem Header="Source">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="22"/>
                        </Grid.RowDefinitions>
                        <pg:HtmlSourceTextEditor x:Name="htmlSourceTextEditor" Grid.Row="0" Html="{Binding Path=PropertyValue, Mode=TwoWay}" MinHeight="20" TextWrapping="WrapWithOverflow" MinWidth="50" AcceptsReturn="True" AcceptsTab="True"/>
                        <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
                            <Button Margin="2,0,2,0" HorizontalAlignment="Right" VerticalAlignment="Center" Width="70"
                                    Command="{Binding Path=UpdateCommand, ElementName=htmlSourceTextEditor}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Margin="0, 0, 2,0" Source="pack://application:,,,/Tum.PDE.ToolFramework.Images;component/Ribbon/Check-16.png" Width="16" Height="16"/>
                                    <TextBlock Text="OK"/>
                                </StackPanel>
                            </Button>
                            <Button Margin="2,0,2,0" HorizontalAlignment="Right" VerticalAlignment="Center" Width="70"
                                    Command="{Binding Path=CancelCommand, ElementName=htmlSourceTextEditor}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Margin="0, 0, 2,0" Source="pack://application:,,,/Tum.PDE.ToolFramework.Images;component/Ribbon/Cancel-16.png" Width="16" Height="16"/>
                                    <TextBlock Text="Cancel"/>
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </Grid>
                </TabItem>
            </TabControl>
        </Grid>
    </DataTemplate>

</ResourceDictionary>